package controller

import (
	"gin/response"
	"gin/service"
	"github.com/gin-gonic/gin"
)

type ReviewRequest struct {
	reviewRequestService service.ReviewRequest
}

// ReviewRecordReq 审核记录请求参数
type ReviewRecordReq struct {
	TenantId uint64 `json:"tenant_id" binding:"required"`
	Page     []int  `json:"page" binding:"required"`
}

// ReviewRecord 审核记录
func (c *ReviewRequest) ReviewRecord(ctx *gin.Context) {
	var req ReviewRecordReq
	err := ctx.ShouldBindJSON(&req)

	if err != nil {
		response.Fail(ctx, nil, err.Error())
		return
	}

	resData, queryErr := c.reviewRequestService.ReviewRecord(req.TenantId, req.Page)
	if queryErr != nil {
		// 查询失败
		response.Fail(ctx, nil, queryErr.Error())
	} else {
		// 查询成功
		response.Success(ctx, gin.H{"data": resData}, "success")
	}
}
